package com.example.design.patterns.geekbang.行为型.策略模式.经典模式;

/**
 * 策略创建: 工厂模式创建一组策略
 * 注意: 适用于策略对象有状态
 */
public class StrategyHaveStateFactory {
    public static Strategy getStrategy(String type) {
        if (type == null || type.isEmpty()) {
            throw new IllegalArgumentException("type should not be empty.");
        }
        if (type.equals("A")) {
            return new ConcreteStrategyA();
        } else if (type.equals("B")) {
            return new ConcreteStrategyB();
        }
        return null;
    }
}